<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
   
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

 
 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>

<script type="text/javascript" src="/Yogiro/js/jquery.js"></script>
	<script type="text/javascript">
	$(document).ready(function(){
		var id = $("#name").val();
		var noticeNo = $("#noticeNo").val();
	
		
		$("#reply").on("click", function(){
			var content = $("#content").val();
			$.ajax({
				"url":"comment.do",
				"type":"post",
				"data":{"method":"insertComment","id":id,"content":content,"noticeNo":noticeNo},
				"dataType":"json",
				"success":function(txt){
					alert("등록되었습니다.");
					var text = "<br><div align='right' style='width:580px'>"
						+"<a href='notice.do?method=deleteComment&commentNo="+txt.commentNo+"&noticeNo="+txt.noticeNo+"'>덧글삭제</a></div>"
					+"<table cellspacing='0' border='1' width='580px' height='25px' style='background:#FFE65A'>"+
					"<tr><td valign='middle' style='color:#FF0033'>"+"작성자:"+txt.memberId+"</td><td style='font-size:12px'> "+txt.commentWritedate+" </td></tr>"
					+ "<table cellspacing='0' border='1' width='580px' height='100px' style='background:#FFFF96'>"+
					"<tr><td valign='top'>"+txt.commentContent+"</td></tr></table>";
					$("#div").append(text);
				},
				"error":function(xhr, status, errorMsg){
					
					alert("등록도중 오류 발생 : "+errorMsg);
				}
			});
		});
		
	});
	
	

	</script>
	
	
</head>
<body>

<table border="1">
	<tr>
		<td  colspan="3" width="570px">${requestScope.list.noticeTO.noticeNo }.  ${requestScope.list.noticeTO.noticeTitle }</td>
	</tr>
	<tr>
		<td>작성자  ┃  ${requestScope.list.noticeTO.noticeWriter }</td><td>작성일  ┃ ${requestScope.list.noticeTO.noticeWritedate } </td><td>조회수  ┃ ${requestScope.list.noticeTO.noticeViewcount } </td>
	</tr>
	<tr>
		<td colspan="3" height="300px">${requestScope.list.noticeTO.noticeContent }</td>
	</tr>
</table>

<input type="hidden" value="${requestScope.list.noticeTO.memberId}" name="mid">
<br>
<br>

	<a href="notice.do?method=deleteContentController&no=${requestScope.list.noticeTO.noticeNo }&page=${param.page }" >글지우기</a>
	<a href="notice.do?method=ModifyFormController&no=${requestScope.list.noticeTO.noticeNo }&page=${param.page }">글수정</a>
	<a href="notice.do?method=NextFormController&no=${requestScope.list.noticeTO.noticeNo }&page=${param.page }"><input type="image" src="img/next.jpg"></a>
	<a href="notice.do?method=PreFormController&no=${requestScope.list.noticeTO.noticeNo }&page=${param.page }">이전글</a>
	<a href="notice.do?method=writeNotice&mid="${sessionScope.mto.memberId }">글쓰기</a>
	<a href="notice.do?method=noticeListController"> 리스트</a>

<div id="div">
		
		<c:forEach items="${requestScope.list.list1 }" var="list">
		<br> 
		<div align='right' style='width:580px'>
			<a href='notice.do?method=deleteComment&commentNo=${list.commentNo }&noticeNo=${list.noticeNo}'>덧글삭제</a></div>
		<table cellspacing='0' border='1' width='580px' height='25px' style='background:#FFE65A'>
			<tr>
				
				<td>작성자: ${list.memberId }</td>
				<td style='font-size:12px'>날짜: ${list.commentWritedate }</td>
			</tr>
		</table>
		<table cellspacing='0' border='1' width='580px' height='100px' style='background:#FFFF96'>
			<tr>
			 <td valign='top'>${list.commentContent }</td>
			</tr>
		</table>
		</c:forEach>
		</div>
		
		<table style="background:#FAF4C0">
		<tr>
			<td><textarea rows="5" cols="60" id="content"></textarea></td>
			<td><input type="button" value="댓글달기" style="background:pink" id="reply"></td>
			
		</tr>
		</table>
		<br>
		
		<input type="hidden" name="id" value="Alice" id="name">
		<input type="hidden" name="noticeNo" value='${requestScope.list.noticeTO.noticeNo }' id="noticeNo">
		
	</body>






</body>
</html>